from app.services.business.gaolu_diagnose.ind.abstract_ind import AbstractInd


class CG_LT_GL_GL04_RFH(AbstractInd):

    def get_name(self):
        return "CG_LT_GL_GL04_RFH"

    def get_sql(self, params):

        sql = """
        SELECT mean(value) AS CG_LT_GL_GL04_RFH  FROM "CG_LT_GL_GL04_RFH"   
        where time > '{dt_start_tz}' and time < '{dt_end_tz}'
        """.format(**params)

        return sql

    @AbstractInd.cache_wrapper
    def get_result(self):
        sql = self.get_sql(self.params)
        client = self.influx_client
        result_set = list(client.query(sql))
        value = self.get_influx_result(result_set, "CG_LT_GL_GL04_RFH")
        return round(value,2)